<template>
	<view class="myorders">
		<view class="myorders-tab">
			<view class="myorders-tab-item" @click="handleTab(0)" :class="{'on':ok==0}">全部</view>
			<view class="myorders-tab-item" @click="handleTab(1)" :class="{'on':ok==1}">待付款</view>
			<view class="myorders-tab-item" @click="handleTab(2)" :class="{'on':ok==2}">代发货</view>
			<view class="myorders-tab-item" @click="handleTab(3)" :class="{'on':ok==3}">代收货</view>
			<view class="myorders-tab-item" @click="handleTab(4)" :class="{'on':ok==4}">售后/退款</view>
		</view>
		<view class="order-list">
			<view class="order-list-box">
				<!-- 数据列表 -->
				<view class="order-item" v-for="(item,index) in list" :key="item.id">
					<navigator :url="'/pages/my/orderinfo?id='+item.payorder" hover-class="none" class="order-top">
						<view class="order-date">订单编号: {{item.payorder}}</view>
						<view class="order-status" v-if="item.ok==1">待付款</view>
						<view class="order-status order-status__org" v-if="item.ok==2">已付款</view>
						<view class="order-status order-status__ok" v-if="item.ok==3">已完成</view>
					</navigator>
					<navigator class="order-shop" :url="'/pages/my/orderinfo?id='+item.payorder" hover-class="none">
						<!-- 此处是商品循环体 -->
						<view class="order-shop-item" v-for="(sitem,sindex) in item.OrderList" :key="sindex">
							<view class="order-shop-bg">
								<view class="jximgbox">
									<view class="jxstips">{{sitem.Class}}</view>
									<image class="jximg" :src="sitem.PicFiles" mode="aspectFit"></image>
								</view>
							</view>
							<view class="order-shop-info">
								<view class="order-shop-info-h1">{{sitem.Titles}}</view>
								<view class="order-shop-info-price">￥{{sitem.Price}}</view>
								<view>
									<view class="order-shop-info-num">
										<uni-icons type="closeempty" size="12" color="#999"></uni-icons>
										<text>{{sitem.count}}</text>
									</view>
								</view>
							</view>
						</view>
						<!-- 此处是商品循环体 END-->
					</navigator>
					<view class="order-shop-tol">
						<view class="order-shop-tol-l">
							<view class="order-shop-tol-h1">
								<uni-dateformat :date="item.paytime" :threshold="[0,0]" format="yyyy-MM-dd"></uni-dateformat>
							</view>
							<view class="order-shop-tol-h2">共{{item.nums}}件商品</view>
						</view>
						<view class="order-shop-tol-r">
							<view class="order-shop-tol-price">
								<view>合计金额 :</view>
								<text>￥{{item.paymoney}}</text>
							</view>
						</view>
					</view>
					<!-- 订单操作按钮组 -->
					<view class="order-btngroup">
						<navigator url="/pages/my/aftersale" class="order-btn" hover-class="none">售后/退款</navigator>
						<button class="order-btn">取消订单</button>
						<button class="order-btn danger">付款</button>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script setup>
	import {
		ref
	} from "vue";
	import {
		onLoad
	} from "@dcloudio/uni-app"
	const ok = ref(0)
	onLoad((options) => {
		const {
			ind
		} = options;
		ok.value = ind;
	})
	const handleTab = (ind) => {
		ok.value = ind;
	}

	const list = ref([{
		id: 1,
		payorder: 2024566700,
		ok: 1,
		nums: 3,
		paymoney: 123.12,
		paytime: '2020/10/20 20:20:20',
		OrderList: [{
			id: 1,
			Class: "中药配方颗粒",
			Titles: '酒白芍配方颗粒酒白芍配方颗粒',
			PicFiles: "http://baihang.com.cn/Upload/image/2021090904LMFFG9.jpg",
			Price: 12.12,
			spcc: "每袋装0.83g",
			count: 3
		}, {
			id: 1,
			Class: "中药配方颗粒",
			Titles: '酒白芍配方颗粒酒白芍配方颗粒',
			PicFiles: "http://baihang.com.cn/Upload/image/2021090904LMFFG9.jpg",
			Price: 12.12,
			spcc: "每袋装0.83g",
			count: 3
		}]
	}, {
		id: 1,
		payorder: 2024566700,
		ok: 1,
		nums: 3,
		paymoney: 123.12,
		paytime: '2020/10/20 20:20:20',
		OrderList: [{
			id: 1,
			Class: "中药配方颗粒",
			Titles: '酒白芍配方颗粒酒白芍配方颗粒',
			PicFiles: "http://baihang.com.cn/Upload/image/2021090904LMFFG9.jpg",
			Price: 12.12,
			spcc: "每袋装0.83g",
			count: 3
		}, {
			id: 1,
			Class: "中药配方颗粒",
			Titles: '酒白芍配方颗粒酒白芍配方颗粒',
			PicFiles: "http://baihang.com.cn/Upload/image/2021090904LMFFG9.jpg",
			Price: 12.12,
			spcc: "每袋装0.83g",
			count: 3
		}]
	}])
</script>

<style lang="scss">
	page {
		background: #f3f3f3;
	}

	.myorders {
		position: absolute;
		top: 0;
		left: 0;
		width: 100%;
		height: 100%;
		display: flex;
		flex-direction: column;
		justify-content: space-between;

		&-tab {
			display: flex;
			align-items: center;
			justify-content: space-between;
			padding: 0 20rpx;
			box-sizing: border-box;
			background: $cf;
			height: 80rpx;
			flex-shrink: 0;
			border-bottom: 1px solid #f3f3f3;

			&-item {
				font-size: 32rpx;
				color: $c3;

				&.on {
					color: $main-color;
				}
			}
		}

		.order-list {
			height: 100%;
			padding: 0 20rpx;
			overflow: auto;

			&-box {
				padding: 20rpx 0;
			}
		}
	}

	.order-item {
		margin-bottom: 20rpx;
		padding: 20rpx;
		background: $cf;
		border-radius: 10rpx;

		&:last-child {
			margin-bottom: 0;
		}

		.order-top {
			display: flex;
			align-items: center;
			justify-content: space-between;
			margin-bottom: 20rpx;

			.order-date {
				font-size: 24rpx;
				color: $c9;
			}

			.order-status {
				font-size: 24rpx;
				color: $red;

				&__org {
					color: #ffaa00;
				}

				&__ok {
					color: $c9;
				}
			}
		}

		.order-shop {
			&-item {
				display: flex;
				margin-bottom: 20rpx;

				&:last-child {
					margin-bottom: 0;
				}
			}

			&-bg {
				width: 185rpx;
				flex-shrink: 0;

				.jximgbox {
					background: #f4f4f4;
					border-radius: 10rpx;
					overflow: hidden;
				}
			}

			&-info {
				flex: 1;
				width: 100%;
				overflow: hidden;
				margin-left: 20rpx;

				&-h1 {
					font-size: 30rpx;
					color: $c0;
					white-space: nowrap;
					overflow: hidden;
					text-overflow: ellipsis;
				}

				&-price {
					display: inline-block;
					border-bottom: 1px solid $c0;
					margin: 10rpx 0;
					font-size: 30rpx;
					color: $c0;
				}

				&-num {
					display: inline-block;
					border-bottom: 1px solid $c9;

					text {
						font-size: 24rpx;
						color: $c9;
					}
				}
			}

			&-tol {
				display: flex;
				align-items: center;
				justify-content: space-between;
				padding: 20rpx 0;
				box-sizing: border-box;
				border-top: 1px solid #eee;
				margin-top: 20rpx;

				&-h1 {
					font-size: 24rpx;
					color: #888;
				}

				&-h2 {
					font-size: 30rpx;
					color: #888;
				}

				&-price {
					display: flex;
					align-items: center;
					font-size: 30rpx;
					padding: 2px 0;
					color: #888;

					text {
						color: $red;
						font-weight: bold;
						margin-left: 2px;
					}
				}

			}
		}


		.order-btngroup {
			text-align: right;
			box-sizing: border-box;

			.order-btn {
				font-size: 30rpx;
				border: 1px solid $c9;
				border-radius: 1000px;
				color: $c9;
				padding: 0 15rpx;
				margin: 0;
				margin-left: 20rpx;
				line-height: 1.7;
				display: inline-block;
				background: none;
				vertical-align: middle;

				&::after {
					display: none;
				}

				&.danger {
					background: $red;
					color: $cf;
					border: none;
				}
			}
		}
	}
</style>